//统一管理用户相关的接口
import request from "@/utils/request";

//统一管理接口
enum API {
    FlowDef_URL = "/itp/cfg/flow/def",
    FlowNode_URL = "/itp/cfg/flow/node",
    FlowProp_URL ='/itp/cfg/flow/node-property',
    FlowCan_URL = '/itp/cfg/flow/node-candidate',
    FlowCheck_URL = '/itp/cfg/flow/node-start-check',
    FlowAround_URL = '/itp/cfg/flow/node-turn-around',
    Spe_URL = '/itp/spe',
    Workflow_URL = '/itp/workflow',
    Delegate_URL = '/itp/delegate'
} 

export default {
    getFlowDefList: (current: number, size: number, data: any) => request.post(`${API.FlowDef_URL}/page?current=${current}&size=${size}`, data),
    saveFlowDef: (param: any) => request.post(`${API.FlowDef_URL}/save`,param),
    detFlowDef: (id: number) => request.get(`${API.FlowDef_URL}/delete?id=${id}`),

    getFlowNode: (id: number) => request.get(`${API.FlowNode_URL}/list?forCfgFlowDefId=${id}`),
    saveFlowNode: (param: any) => request.post(`${API.FlowNode_URL}/save`,param),
    detFlowNode: (id: number) => request.get(`${API.FlowNode_URL}/delete?id=${id}`),

    getFlowPropDefault: () => request.get(`${API.FlowProp_URL}/default`),
    getFlowPropDetail: (id: number) => request.get(`${API.FlowProp_URL}/detail?forCfgFlowNodeId=${id}`),
    saveFlowProp: (param: any) => request.post(`${API.FlowProp_URL}/save`,param),

    getFlowCanDetail: (id: number) => request.get(`${API.FlowCan_URL}/detail?forCfgFlowNodeId=${id}`),
    saveFlowCan: (param: any) => request.post(`${API.FlowCan_URL}/saveList`,param),

    getFlowCheckDetail: (id: number) => request.get(`${API.FlowCheck_URL}/detail?forCfgFlowNodeId=${id}`),
    saveFlowCheck: (param: any) => request.post(`${API.FlowCheck_URL}/saveList`,param),

    getFlowRoundDetail: (id: number) => request.get(`${API.FlowAround_URL}/detail?forCfgFlowNodeId=${id}`),
    saveFlowRound: (param: any) => request.post(`${API.FlowAround_URL}/save`,param),

    saveSpeDraft: (param: any) => request.post(`${API.Spe_URL}/draft/save`,param),
    getSpeDetail: (id: number) => request.get(`${API.Spe_URL}/deployment/detail?id=${id}`),
    
    //获取流程定义列表
    getFlowListPage: (current: number, size: number, searchKey: string) => request.get(`${API.Spe_URL}/proc/def/page?current=${current}&size=${size}&searchKey=${searchKey}`), 
    //获取流程图分页数据
    getFLowDefListPage: (current: number, size: number,param:any) => request.post(`${API.Spe_URL}/deployment/page?current=${current}&size=${size}`,param),
    //复制成新草稿
    copyToDraft: (id: number) => request.get(`${API.Spe_URL}/copy/to/draft?id=${id}`),
    //删除草稿
    deleteDraft: (id: number) => request.get(`${API.Spe_URL}/draft/delete?id=${id}`),
    //获取动态用户
    getDynamicsUserList: () => request.get(`${API.Spe_URL}/dynamic/user`),

    releaseDeployment: (id: number, version: string) => request.get(`${API.Spe_URL}/deployment/save?id=${id}&version=${version}`),
    getLastVersion: (id: number) => request.get(`${API.Spe_URL}/deployment/lastVersion/?id=${id}`),
    getSpeFlowDefDetail: (id: number) => request.get(`${API.Spe_URL}/proc/def/detail?id=${id}`),
    saveSpeFlowDef: (param: any) => request.post(`${API.Spe_URL}/proc/def/save`,param),
    detSpeFlowDef: (id: number) => request.get(`${API.Spe_URL}/proc/def/delete?id=${id}`),

    // 下拉框-流程流转指定方法
    selectTurnAroundMethod: (searchKey: string) => request.get(`${API.Spe_URL}/select/turnAround/method?searchKey=${searchKey}`),
    // 下拉框-启动校验指定方法
    selectStartCheckMethod: (searchKey: string) => request.get(`${API.Spe_URL}/select/startCheck/method?searchKey=${searchKey}`),
    // searchKey 下拉框-表单字段
    selectFormColumn: (procDefId: number, searchKey: string) => request.get(`${API.Spe_URL}/select/form/column?procDefId=${procDefId}&searchKey=${searchKey}`),
    // 下拉框-候选人指定方法
    selectCandidateMethod: (searchKey: string) => request.get(`${API.Spe_URL}/select/candidate/method?searchKey=${searchKey}`),
    // 操作日志
    getFLowLog: (current: number, size: number,param:any) => request.post(`${API.Spe_URL}/operate/log?current=${current}&size=${size}`,param),
    
    selectFormColumnInfo: (param: string) => request.get(`${API.Spe_URL}/select/form/column/info?${param}`),
    getWorkflowList: (current: number, size: number,param:any) => request.post(`${API.Workflow_URL}/page?current=${current}&size=${size}`,param),
    startWorkflow: (param: any) => request.post(`${API.Workflow_URL}/start`,param),
    initWorkflow: (procDefCode: string) => request.get(`${API.Workflow_URL}/init?procDefCode=${procDefCode}`),
    detailWorkflow: (param: string ) => request.get(`${API.Workflow_URL}/detail?${param}`),
    getWorkflowStep: (procInstanceId: any) => request.get(`${API.Workflow_URL}/history/step?procInstanceId=${procInstanceId}`),
    stopWorkflow: (param: any) => request.post(`${API.Workflow_URL}/stop`, param),
    restartWorkflow: (param: any) => request.post(`${API.Workflow_URL}/restart`, param),
    revokeWorkflow: (param: any) => request.post(`${API.Workflow_URL}/revoke`, param),
    addCountersign: (param: any) => request.post(`${API.Workflow_URL}/add/countersign`, param),
    confirmSecond:(param: any)=>request.post(`${API.Workflow_URL}/second/confirm`,param),
    
    getAuditTaskPage: (current: number, size: number, param: any) => request.post(`${API.Workflow_URL}/audit/task/page?current=${current}&size=${size}`, param),
    postDelegateList:(current: number, size: number,param: any) => request.post(`${API.Delegate_URL}/page?current=${current}&size=${size}`,param),
    getDelegateDetail:(id: number)=>request.get(`${API.Delegate_URL}/detail?id=${id}`),
    saveDelegate:(param: any)=>request.post(`${API.Delegate_URL}/save`,param),
    deleteDelegate:(id: number)=>request.get(`${API.Delegate_URL}/delete?id=${id}`)
    
}
